import bibleIndex
import json


log = logging.getLogger(__name__)

class QuerybibleController(BaseController):
    def __init__(self):
        self.bibletext = 'webbible/save/kjb.txt'
        self.bibleloc = 'webbible/save/bible.sav'
        self.indexloc= 'webbible/save/index.sav'
        self.bookToNumLoc = 'webbible/save/bookToNum.sav'

    def _start_(self):
        b = bible.bible()
        b.init(self.bibletext,self.bibleloc,self.bookToNumLoc)
        bibleIndex.createIndex(self.indexloc,b)



    def query(self):
        return 'hello'
        if request.method == 'GET':
            showReq = json.loads(str(request.params['json']))
            ret = []
            i = 0
            bookNameToNum, bookNumToName = bible.loadBookNum(self.bookToNumLoc)
            print(showReq['query'])
            for (b,c,v) in (
                 bibleIndex.lookup(self.indexloc,str(showReq['query']))):
                if i == 7:
                    break
                else:
                    i = i +1
                    ret.append( ({'bookname':bookNumToName[b],'chapterNum':c, 'verseNum':v,'verse':bibl
e.lookup(self.bibleloc,b,c,v)}))
                return json.dumps(ret)
        return ''
        # Return a rendered template
        #return render('/querybible.mako')
        # or, return a string
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"querybible.py" 45L, 1504C written                                                   40,91         Bot
